package com.christianposta.learnddd.domain.model.cargo;

import org.apache.commons.lang.Validate;

import com.christianposta.learnddd.domain.shared.ValueObject;

public class TrackingId implements ValueObject<TrackingId> {
	
	private String id;
	
	/*
	 * Needed by Hibernate?
	 */
	private TrackingId(){
		
	}
	public TrackingId(final String id){
		Validate.notNull(id);
		this.id = id;		
	}

	public boolean sameValueAs(TrackingId other) {
		return other != null && this.id == other.id;
	}
	
	public String idString(){
		return id;
	}
	@Override
	public int hashCode() {
		return id.hashCode();
	}
	@Override
	public boolean equals(Object o) {
	    if (this == o) return true;
	    if (o == null || getClass() != o.getClass()) return false;

	    TrackingId other = (TrackingId) o;

	    return sameValueAs(other);
	}
	
	@Override
	public String toString() {
		return id;
	}

}
